<template>
  <div>
    <ul>
      <li v-for="(item,index) in arr" :key="index">
        {{item}}
        <button @click="shan(index)">删除</button>
      </li>
    </ul>
      <button @click="fn">生成</button>
  </div>
</template>

<script>
export default {
data(){
  return {
arr:[1,2,3,4,5]
  }
},
methods:{
  fn(){
this.arr.push(Math.random()*10);//0到十的随机数
  },
  shan(index){
this.arr.splice(index,1)
  }
}
}
</script>

<style>

</style>